<? 
   include("mysql.php");
    $sql = mysql_query ("SELECT * FROM unit");


while ($db = mysql_fetch_object($sql))
     {
     $id [] = $db -> id;
     $name [] = $db -> name;
     $unit_limit[] = $db -> unit_limit;
     }
$n=sizeof($_GET);
echo "you set $n units <br>";

	for ($i = ; $i <=$n; $i++) 
	{
		if ($unit_limit[$_GET[id.$i]]) 
		{
		echo $i ," ", $name [$_GET[id.$i]], "<br>";
		$unit_limit[$_GET[id.$i]]--;
		}
	}

echo
" <form method = \"post \">
    <select name = \"id$n\">";
       for ($i = 0; $i < count($name); $i++)
	   {
		if ($unit_limit[$i]) 
		{
	echo "<option value=\"$id[$i]\">$unit_limit[$i] $name[$i] </option>";
		}
	}
echo  "</select>";
echo '<input type="submit" value="add">';
mysql_close($dp);
?>
